#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>

#include <unistd.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netinet/tcp.h>

int main(int argc, char* argv[]) {
	int sockfd, connfd;
	struct sockaddr_in server_addr;
	struct sockaddr_in client_addr;
	int len = sizeof(server_addr);

	server_addr.sin_family = AF_INET;
	server_addr.sin_addr.s_addr = inet_addr("127.0.0.1");
	server_addr.sin_port = htons(4567);

	sockfd = socket(AF_INET, SOCK_STREAM, 0);
	connect(sockfd, (struct sockaddr*)&server_addr, len);	

	char buf[100] = {0};
	char c1 = 'H', c2 = 'E', c3 = 'L', c4 = 'L';
	
	/*
	struct iovec v[4];
	v[0].iov_base = &c1; v[0].iov_len = 1;
	v[1].iov_base = &c2; v[1].iov_len = 1;
	v[2].iov_base = &c3; v[2].iov_len = 1;
	v[3].iov_base = &c4; v[3].iov_len = 1;	
	writev(sockfd, v, 4);
	*/
	
	/*
	int nodelay = 1;
	setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, &nodelay, sizeof(int));
	write(sockfd, &c1, 1);
	write(sockfd, &c2, 1);
	write(sockfd, &c3, 1);
	write(sockfd, &c4, 1);
	*/
	
	read(sockfd, buf, 100);
	printf("cli_read: %s\n", buf);
	close(sockfd);
	return 0;
}
